<!--
 * @FilePath     : /study_code/vue2.x/Vue.directive1.html
 * @Description  : Vue.directive 钩子使用示例
 * @Date         : 2025-05-03 08:58:30
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-05-03 08:58:35
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
    <link rel="stylesheet" href="" />
  </head>
  <body>
    <div id="app">
      <div id="hook-arguments-example" v-demo:foo.a.b="message"></div>
    </div>

    <script src="/vue/dist/vue.min.js"></script>
    <script src="./common.js"></script>
    <script>
      // 全局-自定义指令
      Vue.directive('demo', {
        bind: function (el, binding, vnode) {
          var s = JSON.stringify
          console.log('el', el)
          console.log('binding', binding)
          console.log('vnode', vnode)
          el.innerHTML =
            'name: ' +
            s(binding.name) +
            '<br>' +
            'value: ' +
            s(binding.value) +
            '<br>' +
            'expression: ' +
            s(binding.expression) +
            '<br>' +
            'argument: ' +
            s(binding.arg) +
            '<br>' +
            'modifiers: ' +
            s(binding.modifiers) +
            '<br>' +
            'vnode keys: ' +
            Object.keys(vnode).join(', ')
        },
        /*
        name: "demo"
        value: "hello!"
        expression: "message"
        argument: "foo"
        modifiers: {"a":true,"b":true}
        vnode keys: tag, data, children, text, elm, ns, context, fnContext, fnOptions, fnScopeId, key, componentOptions, componentInstance, parent, raw, isStatic, isRootInsert, isComment, isCloned, isOnce, asyncFactory, asyncMeta, isAsyncPlaceholder
        */
      })

      var app = new Vue({
        el: '#app',
        data: function () {
          return { message: 'hello!' }
        },
      })
    </script>
  </body>
</html>
